package com.kefu.call.vo;

import javax.validation.constraints.Size;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import com.kefu.call.model.CallGateway;
import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "网关表")
public class CallGatewayInsertVo extends AbstractInsertVo<CallGateway> {
    @ApiModelProperty(value = "名称",hidden = true)
    private String name;
    @ApiModelProperty(value = "名称")
    private String memo;

    @ApiModelProperty(value = "注册的地址")
    private String realm;
    
    @ApiModelProperty(value = "是否注册【true或false】")
    private String register;
    
    @ApiModelProperty(value = "发件人字段中使用的用户名如果为空，则默认为用户名")
    private String fromuser;

    @ApiModelProperty(value = "并发数量")
    private Integer concurrent;
    
    @ApiModelProperty(value = "注册用户名")
    private String username;
    
    @ApiModelProperty(value = "密码")
    private String password;
    
    @ApiModelProperty(value = "验证用户名")
    private String authusername;
    
    @ApiModelProperty(value = "显示在from中的名称")
    private String calleridinfrom;
    
    @ApiModelProperty(value = "联系分机")
    private String extension;
    
    @ApiModelProperty(value = "SIP联系人头中发送分机")
    private String extensionincontact;
    
    @ApiModelProperty(value = "代理")
    private String proxy;
    
    @ApiModelProperty(value = "联系地址")
    private String context;
    
    @ApiModelProperty(value = "注册秒，默认3600")
    private String expireseconds;
    
    @ApiModelProperty(value = "重试注册的秒数")
    private String retryseconds;
    
    @ApiModelProperty(value = "发件人用户")
    private String fromdomain;
    
    @ApiModelProperty(value = "from字段中使用的域")
    private String registerproxy;
    
    @ApiModelProperty(value = "注册的代理")
    private String contactparams;
    
    @ApiModelProperty(value = "寄存器传输【如果已启用，则为udp，tcp或tls】")
    private String registertransport;
    
    @ApiModelProperty(value = "驱动[profile]id")
    private String profileoid;
    
    @ApiModelProperty(value = "公司ID")
    private String company;
    @ApiModelProperty(value = "是否启用，0未启用，1启用")
    private Integer enablegw;
    
    @ApiModelProperty(value = "归属")
    private String gs;
    
    @ApiModelProperty(value = "区号")
    private String qh;
    
    @ApiModelProperty(value = "免费通话时间[本月]")
    private String rentalminute;
    @ApiModelProperty(value = "当月套餐")
    private Integer setmealoid;
    
    @ApiModelProperty(value = "下次同步时间")
    private String synctime;
    @ApiModelProperty(value = "下月生效套餐")
    private Integer setmealoidU;
    
    @ApiModelProperty(value = "消费[本月]")
    private String consumption;

    @ApiModelProperty(value = "创建人")
    private String createName;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "被叫前缀")
    private String callprefix;

    @Override
    public CallGateway convert() {
        CallGateway info = new CallGateway();
        info.setFOid(IdWorker.getIdStr());
        info.setName(info.getFOid());
        info.setMemo(memo);
	    info.setRealm(realm);
	    info.setRegister(register);
	    info.setFromuser(fromuser);
	    info.setConcurrent(concurrent);
	    info.setUsername(username);
	    info.setPassword(password);
	    info.setAuthusername(authusername);
	    info.setCalleridinfrom(calleridinfrom);
	    info.setExtension(extension);
	    info.setExtensionincontact(extensionincontact);
	    info.setProxy(proxy);
	    info.setContext(context);
	    info.setExpireseconds(expireseconds);
	    info.setRetryseconds(retryseconds);
	    info.setFromdomain(fromdomain);
	    info.setRegisterproxy(registerproxy);
	    info.setContactparams(contactparams);
	    info.setRegistertransport(registertransport);
	    info.setProfileoid("external");
	    info.setCompany(company);
	    info.setEnablegw(enablegw);
	    info.setGs(gs);
	    info.setQh(qh);
//	    info.setRentalminute("0");
	    info.setSetmealoid(setmealoid);
//	    info.setSynctime(DateUtil.date().toString("yyyy-MM"));
	    info.setSetmealoidU(setmealoidU);
//	    info.setConsumption("0");
        info.setCreateName(KefuContext.getKefuContext().getUserName());
        info.setCreateTime(DateUtil.date());
        info.setCallprefix(callprefix);
	    return info;
	}
}